﻿using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using UnityEngine;
using UnityEngine.UI;

public class HPshow: MonoBehaviour
{
    RectTransform frame;
    Text data;
    float orilenth;
    public int hp,maxhp;

    // Start is called before the first frame update
    void Start()
    {
        frame = GetComponent<RectTransform>();
        orilenth = frame.rect.width;
        maxhp = 100;
        data = this.gameObject.GetComponentInChildren<Text>();
    }

    // Update is called once per frame
    void Update()
    {
        data.text = hp + "/" + maxhp;
        frame.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, orilenth * hp / (float)maxhp);
    }
}
